import { fetch } from 'plugins/axios'

export function loadHostsNum ({ commit }) {
  return new Promise((resolve, reject) => {
    fetch('/dashboard/count_for_hosts/', {}).then((response) => {
      commit('loadHostsNum', JSON.parse(response))
      resolve()
    }).catch((error) => {
      console.log(error.response.data.detail)
    })
  })
}

export function loadMiddleStatus ({ commit }) {
  return new Promise((resolve, reject) => {
    fetch('/dashboard/middle_ware_status/', {}).then((response) => {
      commit('loadMiddleStatus', JSON.parse(response))
      resolve()
    }).catch((error) => {
      console.log(error.response.data.detail)
    })
  })
}
